'use strict';

describe('passwordService', function () {
  console.log("-------------test passwordService-------------");
  // load the service's module
  beforeEach(module('passwordAgentApp'));

  // instantiate service
  var passwordService;
  var scope;
  //beforeEach(inject(function ($service) {
  //  passwordService = $service("");
  //}));


  beforeEach(inject(function ($injector, $rootScope) {
    scope = $rootScope.$new();
    passwordService = $injector.get("passwordService");
  }));

  it('should do something', function () {
    console.log("scope========" + scope);
    console.log("passwordService========" + passwordService);
    //var condition = passwordService.newCondition();
    var condition = new passwordService.Condition();
    condition.userName = "zhangsan";
    condition.length = 8;
    console.log("condition========" + condition);
    console.log("condition.hashCode()========" + condition.hashCode());
    expect(!!scope).toBe(true);
  });

  it('test all length', function () {
    for (var i = 0; i < 100; i++) {
      var condition2 = new passwordService.Condition();
      condition2.length = i;
      var word2 = passwordService.produceWord(condition2);//06448684
      console.log("word2 ============ " + word2);
      console.log("condition2.hashCode() ============ " + condition2.hashCode());
      //expect(condition2.hashCode() == -655394414).toBe(true);//-289258472
      expect(word2 != null && word2 != "").toBe(true);
    }
  });

  it('HashCode Test!', function () {
    //Condition condition = new Condition();
    //condition.setPattern("dddddddd");
    //
    //Set<Answer> answers = new HashSet<Answer>();
    //Answer answer = new Answer();
    //answer.setAsk("我的id");
    //answer.setAnswer("111");
    //Answer answer2 = new Answer();
    //answer2.setAsk("我的名字");
    //answer2.setAnswer("张三");
    //answers.add(answer);
    //
    //condition.setAnswers(answers);
    //condition.setUserName("blademainer");
    //condition.setWebSite("baidu.com");
    //-289258472

    var condition2 = new passwordService.Condition();
    //condition2.pattern = "dddddddd";
    condition2.email = "blademainer@gmail.com";
    condition2.webSite = "baidu.com";

    var answers2 = condition2.answers;
    var answer3 = new passwordService.Answer();
    answer3.ask = "我的id";
    answer3.answer = "111";
    var answer2 = new passwordService.Answer();
    answer2.ask = "我的名字";
    answer2.answer = "张三";
    answers2.push(answer3);
    answers2.push(answer2);
    condition2.pattern = "Wwwwwwww";
    var word2 = passwordService.produceWord(condition2);//06448684
    console.log("word2 ============ " + word2);
    console.log("condition2.hashCode() ============ " + condition2.hashCode());
    expect(condition2.hashCode() == -655394414).toBe(true);//-289258472
    expect(word2 == "Zcgrjbbp").toBe(true);
    //var i = 1;
    //while (i > 0){
    //  i++;
    //  //console.log("i========="+i);
    //  if(i < 0){
    //    console.log("min========="+i);
    //  }
    //}

  })

});
